package cn.aihongbo.kmp.data.repository

import cn.aihongbo.kmp.base.net.HNet
import cn.aihongbo.kmp.data.API_URL_HBC_CONFIG_BANNER
import cn.aihongbo.kmp.data.API_URL_HBC_CONFIG_OPERATION_GIFT
import cn.aihongbo.kmp.data.API_URL_HBC_QUERY_CLASSIC_TRAVEL
import cn.aihongbo.kmp.data.API_URL_HBC_QUERY_TRAVEL_DICT
import cn.aihongbo.kmp.data.bean.HbcConfigBannerBean
import cn.aihongbo.kmp.data.bean.HbcConfigOperationGiftBean
import cn.aihongbo.kmp.data.bean.QueryClassicTravelBean
import cn.aihongbo.kmp.data.bean.TravelDictBean
import cn.aihongbo.kmp.data.request.RequestBics
import cn.aihongbo.kmp.data.request.RequestClassicTravel
import cn.aihongbo.kmp.data.request.RequestConfigOperationGift
import kotlinx.coroutines.flow.Flow

class BicsRepository {

    private fun hbcConfigBanner(keywordGroup: String): Flow<HbcConfigBannerBean> {
        val request = RequestBics(keywordGroup, 10, 1, 1)
        return HNet.ins.post<HbcConfigBannerBean>(API_URL_HBC_CONFIG_BANNER, request)
    }

    fun getHomeTopImageBanner(): Flow<HbcConfigBannerBean> = hbcConfigBanner("capp首页banner")

    fun getHomeRedHotBanner(): Flow<HbcConfigBannerBean> = hbcConfigBanner("当季热门")

    fun getHomeConfigOperationGift(): Flow<HbcConfigOperationGiftBean> = HNet.ins.post(
        API_URL_HBC_CONFIG_OPERATION_GIFT, RequestConfigOperationGift("运营位-新用户")
    )

    fun getHomeQueryTravelDict(): Flow<List<TravelDictBean?>> =
        HNet.ins.get(API_URL_HBC_QUERY_TRAVEL_DICT)

    fun getClassicTravel(group: TravelDictBean?): Flow<QueryClassicTravelBean> = HNet.ins.post(
        API_URL_HBC_QUERY_CLASSIC_TRAVEL, RequestClassicTravel(
            1, 20, "", "", "", emptyArray(), emptyArray(), emptyArray(), "${group?.travelLineId}"
        )
    )
}